﻿var dialog;

$(onPageLoad);

function onPageLoad() {
	dialog = window.frameElement;
	$("#cmdOK").click(onUpdate);
	$("#cmdCancel").click(onCancel);
	$("#txtSiteTitle")
		.val(dialog.dialogArgs.title)
	  .focus()
	  .select();
}

function onUpdate() {
	var NewTitle = $("#txtSiteTitle").val();
	dialog.commonModalDialogClose(SP.UI.DialogResult.OK, { title: NewTitle });
}

function onCancel() {
	dialog.commonModalDialogClose(SP.UI.DialogResult.cancel);
}